/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-04 09:50:21
 * @LastEditTime : 2023-07-05 09:25:58
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\HelmetSoS.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { ExecuteButton, DelDataButton } from '../Common/options'

export const HelmetSoS = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1, isEnabled: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'organizationName',
                title: '组织机构',
                rules: true,
                valueType: 'select',
                ellipsis: true,
                width: 100,
                valueEnum: BuiltInData.RequestType,
                hideInSearch: true,
            },
            { ...commonTableList.tableName },
            { ...commonTableList.code, hideInSearch: true },
            {
                dataIndex: 'helmetSOSType',
                title: '报警类型',
                rules: true,
                valueType: 'select',
                ellipsis: true,
                width: 100,
                valueEnum: BuiltInData.RequestType,
                hideInSearch: true,
            },
            {
                dataIndex: 'personName',
                title: '人员姓名',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 150,
                hideInSearch: true,
            },

            {
                dataIndex: 'lat',
                title: '纬度',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'helmetSoSId',
                title: '序列号',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'lng',
                title: '经度',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 150,
                hideInSearch: true,
            },
            { ...commonTableList.isEnabled, rules: true },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid, isEnabled } = record
                    return [
                        isEnabled === 0 && (
                            <ExecuteButton
                                actionRef={actionRef}
                                key="one"
                                title="解除报警"
                                url="posHelmetSoSUpdateIsEnabled"
                                path={[uuid]}
                                tips="已处置报警信息!"
                            />
                        ),
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
